global Y_p A
global Y_mu B
local Y  p mu
foreach y of local Y{
eststo clear

* Buyer - excluded products baseline metric   
eststo: reghdfe ln_`y'_sbjo  sourcing_metric_b_excl   signatory  ///
 ln_q_b_all age_buy_month ln_p_inpf_sbjo ln_q_sbjo  if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,O}", replace  
  quietly estadd local CTRL2 =".", replace  
  quietly estadd local est ="\scriptsize{All}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd scalar  U =  . , replace  
 
 * Buyer - average of excluded products  
eststo: reghdfe ln_`y'_sbjo  Mwav_sourcing_metric_be  signatory  ///
 ln_q_b_all age_buy_month ln_p_inpf_sbjo ln_q_sbjo  if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,O}", replace  
  quietly estadd local CTRL2 =".", replace  
  quietly estadd local est ="\scriptsize{All}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd scalar  U =  . , replace     

 
* Relationship - all products
eststo: reghdfe ln_`y'_sbjo  Msourcing_metric_sb   signatory  ///
 ln_q_b_all age_buy_month ln_p_inpf_sbjo ln_q_sbjo  if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,O}", replace  
  quietly estadd local CTRL2 =".", replace  
  quietly estadd local est ="\scriptsize{All}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd scalar  U =  . , replace     

  
 * Buyer (excluded) and relationship - all products demeaned
eststo: reghdfe ln_`y'_sbjo  Mwav_sourcing_metric_be  Mdwav_sourcing_metric_sb  signatory  ///
 ln_q_b_all age_buy_month ln_p_inpf_sbjo ln_q_sbjo  if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,O}", replace  
  quietly estadd local CTRL2 =".", replace  
  quietly estadd local est ="\scriptsize{All}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd scalar  U =  . , replace   

 * Buyer (excluded) and relationship - all products demeaned; buyer fixed effects
eststo: reghdfe ln_`y'_sbjo    Mdwav_sourcing_metric_sb  signatory  ///
 ln_q_b_all age_buy_month ln_p_inpf_sbjo ln_q_sbjo  if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b b_id ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,O}", replace  
  quietly estadd local CTRL2 =".", replace  
  quietly estadd local est ="\scriptsize{All}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd scalar  U =  . , replace   
 
esttab using "${tables}\TableC6Panel${Y_`y'}.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
      title("Relational Buyers and Relationships" \label{Relationships}) ///
  drop(ln_q_b_all age_buy_months  signatory ln_q_sbjo ln_p_inpf_sbjo _cons  ) order(    ) /// 
  stats(FE CTRL est r2   N   , fmt( %~#s %~#s %~#s   2 %12.0fc  )  ///
  labels("FEs" "Controls" "Sample" `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes   
 } 